package com.listeningframework.boot.autoconfigure.template.freemarker.templates;

import javax.annotation.PostConstruct;

import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;

import com.listeningframework.boot.autoconfigure.template.freemarker.overrides.ListeningFreemarkerSimpleHash;
import com.listeningframework.boot.autoconfigure.template.freemarker.templates.security.SecurityHasPermission;

/**
 * 自定义标签汇总
 * 
 * @author lixining
 * @version $Id: ListeningTags.java, v 0.1 2014年7月8日 下午5:20:16 lixining Exp $
 */
@Component
@ConditionalOnClass({ freemarker.template.Configuration.class, Authentication.class })
public class ListeningSecurityFreemarkerSimpleHash extends ListeningFreemarkerSimpleHash {

    /**  */
    private static final long   serialVersionUID = 316766354957047446L;

    private static final String VARIABLE         = "listening";

    @Override
    public String getVariable() {
        return VARIABLE;
    }

    @Override
    @PostConstruct
    public void execute() {
        addTag(SecurityHasPermission.class, "hasPermission");
    }

}
